using System.Collections.Generic;
using System.Linq;
using Magiq.Support;

namespace Magiq.Databases.SqlServer
{
    public class SqlServerDialect : IDialect
    {
        public string DeleteClauseFor(string tableName, string from)
        {
            return string.Format("DELETE {0} FROM {1}", tableName, from);
        }

        public string UpdateClauseFor(string tableName, IDictionary<string, string> sets, string from)
        {
            return string.Format("UPDATE {0} SET {1} FROM {2}", tableName, sets.Select(x => x.Key + "=" + x.Value).Join(","), from);
        }

        public string InsertClauseFor(string tableName, IDictionary<string, string> columnValues, string from)
        {
            return string.Format("INSERT INTO {0} ({1}) SELECT {2} FROM {3}", tableName, columnValues.Keys.Join(","), columnValues.Values.Join(","), from);
        }

        public static IDialect Instance = new SqlServerDialect();

        private SqlServerDialect()
        {
        }
    }
}